using Backoffice.Domain.Entities;
using Backoffice.Domain.Entities.App;

namespace BackOffice.Domain.Entities.App;

public class AppFileShare : EntityBase
{
    public Guid FileId   { get; private set; }
    public Guid SharedTo { get; private set; }   // 目标用户
    public DateTime ExpireAt { get; private set; }
    public ShareMode Mode    { get; private set; }

    /* 导航属性 */
    public virtual AppFile File { get; private set; } = null!;

    private AppFileShare() { }

    public AppFileShare(Guid fileId, Guid sharedTo, DateTime expireAt, ShareMode mode)
    {
        FileId   = fileId;
        SharedTo = sharedTo;
        ExpireAt = expireAt;
        Mode     = mode;
    }

    public void Extend(DateTime newExpire) => ExpireAt = newExpire;
    public void ChangeMode(ShareMode newMode) => Mode = newMode;
}

public enum ShareMode
{
    ReadOnly,
    ReadWrite
}
